package com.example.mahoutdemo.controller;

import com.example.mahoutdemo.core.customer.commodity.operation.CustomerCommodityOperationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.mahout.cf.taste.common.TasteException;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("customer-commodity-operation")
@Validated
@Slf4j
@Api(tags = "用户商品操作行为管理")
public class CustomerCommodityOperationController {

    private final CustomerCommodityOperationService service;

    public CustomerCommodityOperationController(CustomerCommodityOperationService service) {
        this.service = service;
    }
    /**
     * 根据用户喜好推送视频
     * @return
     */
    @ApiOperation("根据用户喜好推送")
    @GetMapping("/recommendations/{customerId}")
    public List<Long> recommend(@PathVariable Long customerId) throws TasteException {
        return service.recommend(customerId);
    }
/**
     * 根据用户喜好推送视频
     * @return
     */
    @ApiOperation("根据商品推送")
    @GetMapping("/item/recommendations/{itemId}")
    public List<Long> recommendItem(@PathVariable Long itemId) throws TasteException {
        return service.recommendItem(itemId);
    }

}
